package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.LitemallTopicMapper;
import org.linlinjava.litemall.db.domain.LitemallTopic;
import org.linlinjava.litemall.db.domain.LitemallTopicExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author Administrator
 */
@Service
public class LitemallTopicService {
    @Resource
    private LitemallTopicMapper topicMapper;

    public int create(LitemallTopic topic) {
        topic.setAddTime(LocalDateTime.now());
        topic.setUpdateTime(LocalDateTime.now());
        return topicMapper.insertSelective(topic);

    }

    public int update(LitemallTopic topic) {
        topic.setUpdateTime(LocalDateTime.now());
        return topicMapper.updateByPrimaryKeySelective(topic);
    }

    public int delete(Integer id) {
        return topicMapper.deleteByPrimaryKey(id);
    }

    public List<LitemallTopic> queryList() {
        LitemallTopicExample example = new LitemallTopicExample();
        List<LitemallTopic> litemallTopics = topicMapper.selectByExample(example);
        return litemallTopics;
    }

    public LitemallTopic findById(Integer id) {
        return topicMapper.selectByPrimaryKey(id);
    }





}
